package com.lpwa.common.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.xml.crypto.Data;
import java.util.Date;

/**
 * @Description 静态方法中调用redis
 * @Author qizhentao
 * @Date 2020/7/1 11:27
 * @Version 1.0
 */
@Component
public class StaticRedisUtil {
 
    @Autowired
    private RedisUtil redisUtil;
 
    public static RedisUtil staticRedisUtil;
 
    // 项目启动时把redisUtil交给静态的staticRedisUtil
    @PostConstruct
    public void init() {
        staticRedisUtil = this.redisUtil;
    }
    // 测试静态方法中使用
    public static void set(String key,String value){
        StaticRedisUtil.staticRedisUtil.set(key,value);
    }
}